package ReflectApply.apply1;

import ReflectApply.data.Person;
import org.junit.Test;

/**
 * @author Jimmy Zhan WORKSTATION
 * @date 2023/3/31 17:49
 * 说明：反射的应用一：创建运行时类的对象
 */

public class NewInstanceTest {
    @Test
    public void test1() throws InstantiationException, IllegalAccessException {
        Class clazz = Person.class;

        // 创建Person类的实例
        // newInstance()会调用构造器
        Person p1 = (Person)clazz.newInstance();
        System.out.println(p1);
    }
}
